
//Project Euler Coded by Javascript
var JEuler = {};

(function() {

JEuler.info = {
    version  : "0.1",
    author   : "Eric SHI",
    toString : function() {
        return "Project Euler Coded by Javascript (" + this.version + ")";
    }
};

var extend = function(object, extendObj) {
    for(var p in extendObj) {
        object[p] = extendObj[p];
    }
    return object;
}

var timer = new Date().getTime();

JEuler.system = {

    print : function(msg) {
        return print(msg);
    },
    
    loadJS : function(path) {
        return load(path);
    },
    
    printCaption : function(no) {
        this.print("-----------------------------------------------------");
        this.print(" " + JEuler.info.toString() + " Problem " + no);
        this.print("-----------------------------------------------------");
        this.print("");
    },
    
    startTimerCount : function() {
        timer = new Date().getTime();
    },
    
    endTimerCount : function() {
        return (new Date().getTime() - timer);
    },
    
    printTimerCount : function() {
        JEuler.system.print("Calculated in " + this.endTimerCount()/1000 + "s");
    }
};

JEuler.extend = extend;

var $Array = {
    each : function(f) {
        for(var i=0; i<this.length; i++) {
            f.call(this, this[i], i);
        }
        return this;
    }
};

JEuler.$A = function(array) {
    return extend(array, $Array);
};

})();

//Predefined packages
JEuler.math = {};
